﻿@using DualControl.CommonServices
@using DualControl.ControlMeasures.Dtos

@model Abp.Application.Services.Dto.ListResultDto<HTCriteriaListDto>
@using X.PagedList.Mvc.Core; @*import this so we get our HTML Helper*@
@using X.PagedList; @*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@

@inject ICommonService CommonService

@{
    ViewData["Title"] = "主要管控措施";
}

@section scripts
    {
    <environment names="Development">
        <script src="~/view-resources/Views/ControlMeasures/HiddenTroubleCriteria.js" asp-append-version="true"></script>
    </environment>
    <environment names="Staging,Production">
        <script src="~/view-resources/Views/ControlMeasures/HiddenTroubleCriteria.min.js" asp-append-version="true"></script>
    </environment>
}
<style>
    .table tbody tr th td {
        vertical-align: middle;
    }
</style>

<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    @L("HiddenTroubleCriteria")
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>@L("Refresh")</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">



                @foreach (var hazardsource in ViewBag.PageOfHTCriteriaListDto)
                {

                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            风险点编码：@hazardsource.Code &nbsp; 车间/班组：@CommonService.GetOrganizationUnits().SingleOrDefault(c => c.Key == @hazardsource.OrganizationUnitId).Value  风险点名称：@hazardsource.RiskPointName   &nbsp;
                        </h3>
                    </div>
                    <div class="panel-body">
                        <h4 class="panel-title">
                            危险源名称: @hazardsource.HazardSourceName   &nbsp;风险因素:@hazardsource.RiskFactor &nbsp; 隐患级别:  @hazardsource.RiskLevel
                            &nbsp;责任人: @hazardsource.ResponsiblePerson
                        </h4>

                    </div>
                    <table class="table">
                        <thead>
                            <tr>
                                <th width="10%">序号</th>
                                <th width="30%">管控措施</th>
                                <th>排查周期</th>
                                <th>岗位</th>                               
                                <th width="30%">操作</th>
                            </tr>
                        </thead>

                        @{ if (hazardsource.ControlMeasures.Count > 0)
                                {


                                    int i = 0;

                            @foreach (var controlmeasure in hazardsource.ControlMeasures)
                                    {

                                        i++;
                            <tr>
                                <td>@i.</td>
                                <td>
                                    @controlmeasure.ControlContent
                                </td>
                                <td>
                                    @{
                                                    if (controlmeasure.CheckCycle != null)
                                                    {
                                        @controlmeasure.CheckCycle;
                                                    }
                                    }
                                </td>
                                <td>
                                    @{
                                                    if (controlmeasure.PostId != null)
                                                    {
                                        @CommonService.GetPosts().SingleOrDefault(c => c.Key == controlmeasure.PostId).Value
                                                    }
                                    }
                                </td>    
                                <td>
                                    <span class="glyphicon glyphicon-pencil"></span>
                                    <button class="edit-controlmeasure" data-controlmeasure-id="@controlmeasure.Id"
                                            data-organizationunit-id="@controlmeasure.OrganizationUnitId"
                                            data-post-id="@controlmeasure.PostId"
                                            data-user-id="@*@controlmeasure.UserId*@"
                                            data-checkcycle="@controlmeasure.CheckCycle"
                                            data-toggle="modal" data-target="#HiddenTroubleCriteriaEditModal">
                                        编辑
                                    </button>
                                </td>
                            </tr>

                                    }
                                }

                        }
                    </table>

                </div>
                }
            </div>
        </div>
    </div>
</div>

@Html.PagedListPager((IPagedList)ViewBag.PageOfHTCriteriaListDto, page => Url.Action("Index", new { page }))



<div class="modal fade" id="HiddenTroubleCriteriaEditModal" tabindex="-1" role="dialog" aria-labelledby="HazardSourceEditModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>编辑管控措施</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="hazardSourceEditForm" id="eidtform" role="form" novalidate class="form-validation">
                    <input type="hidden" name="Id" id="Id" />               <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-org-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div id="div-checkcycle" class="form-group form-float">
                                        <label class="form-label">管控措施</label>
                                        @Html.DropDownList("CheckCycle", CommonService.GetCheckCycle().Select(c =>
                                              new SelectListItem() { Text = c.Value.ToString(), Value = c.Value.ToString() }), "==排查周期==", new { @class = "form-control" })
                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div id="div-postid" class="form-group form-float">
                                        <label class="form-label">岗位</label>
                                        @Html.DropDownList("PostId",CommonService.GetPosts().Select(c =>
              new SelectListItem() { Text = c.Value.ToString(), Value = c.Key.ToString() }), "==请选择岗位==", new { @class = "form-control" })
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    @*<div class="modal-footer">
                    <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                    <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                </div>*@
                </form>

            </div>
            @Html.Partial("~/Views/Shared/Modals/_ModalFooterWithSaveAndCancel.cshtml")

        </div>
    </div>

</div>
